home *** CD-ROM | disk | FTP | other *** search
- Path: io.UWinnipeg.ca!wsimpson
- From: Bill Simpson <wsimpson@uwinnipeg.ca>
- Newsgroups: comp.lang.c
- Subject: warning: possibly incorrect assignment
- Date: Tue, 9 Jan 1996 09:26:35 -0600
- Organization: The University of Manitoba
- Message-ID: <Pine.OSF.3.91.960109091920.6447A-100000@io.UWinnipeg.ca>
- NNTP-Posting-Host: io.uwinnipeg.ca
- Mime-Version: 1.0
- Content-Type: TEXT/PLAIN; charset=US-ASCII
-
- I get the above warning when I compile code using the following
- function. It flags the **** line.
-
- void save_data(unsigned long int time[],int n)
- {
- char file_name[30];
- double t;
- int i;
- FILE * fp;
-
- printf("Enter file name: ");
- scanf("%s", file_name);
-
- **** while(fp=fopen(file_name,"r"))
- {
- printf("this file already exists--use another name\n");
- fclose(fp);
- printf("Enter filename:\n");
- scanf("%s", file_name);
- }
-
- fp=fopen(file_name,"w");
- for (i=0;i<n;i++)
- {
- t=(double)time[i]/1000000; /*convert from microsec to sec*/
- fprintf(fp,"%.6f\n",t);
- }
- fclose(fp);
-
- return;
- }
-
- How can I write this code so the compiler does not issue this warning?
- Please don't suggest I just tell the compiler to shut up. In general
- the warnings are useful. I do not want to just ignore the warning either.
- I have the FAQ and haven't seen this discussed.
-
- (Any other improvements to above code segment welcomed)
-
- Thanks very much for any help.
-
- Bill Simpson
-